package com.hankol.material.adapter

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentPagerAdapter
import androidx.viewpager.widget.PagerAdapter
import com.hankol.material.fragment.ContentListFragment
import java.util.*


/**
 * @description:
 * @author: 关忆北丶
 * @date :   2021/10/18 13:28
 */
class ContentListPagerAdapter(var fm: FragmentManager) : FragmentPagerAdapter(fm) {
    private var mFragments = ArrayList<ContentListFragment>()
    private var flags: BooleanArray? = null//标识,重新设置fragment时全设为true
    private var time: Long = 0
    fun setFragments(fragments: ArrayList<ContentListFragment>) {
        time = System.currentTimeMillis()
        this.mFragments = fragments
        notifyDataSetChanged()
    }

    override fun getItem(position: Int): Fragment {
        return mFragments[position]
    }

    override fun getCount(): Int {
        return mFragments.size
    }

    override fun getPageTitle(position: Int): CharSequence? {
        return ""
    }


    override fun getItemId(position: Int): Long {
        return super.getItemId(position) + time
    }



    override fun getItemPosition(o: Any): Int {
        return PagerAdapter.POSITION_NONE
    }
}
